
import { onReady } from '@dcloudio/uni-app'
export const useHeight = () => {
	const menuHeight = ref(0)
	const menuTopHeight = ref(0)

	onReady(() => {
		const { statusBarHeight, windowHeight, screenHeight } = uni.getSystemInfoSync()
		menuTopHeight.value = statusBarHeight
		// #ifdef MP-WEIXIN
		// 获取胶囊按钮信息
		const { width, height, top } = uni.getMenuButtonBoundingClientRect()
		const menuButtonInfo = { width, height, top }
		
		// 胶囊按钮相对于离导航栏的上边距
		const topDistance = menuButtonInfo.top - statusBarHeight;
		
		// 计算导航栏高度
		menuHeight.value = menuButtonInfo.height + topDistance * 2;
		// #endif
	})
	return {
		menuHeight,
		menuTopHeight
	}
}
